#pragma once
#include <iostream>
#include <string>
#include <vector>
#define SEP " "
#define SEP_LEN strlen(SEP)
using namespace std;

int toInt(const string &str)
{
    return atoi(str.c_str());
}

bool stringSeparate(const string &str, vector<string> *vs)
{
    size_t start = 0;
    size_t pos = 0;
    while (start < str.size())
    {
        pos = str.find(SEP, start);

        if (pos == string::npos)
        {
            //cout << "没找到SEP" << endl;
            break;
        }
        // cout << "start:" << start << "  "
        //      << "pos:" << pos << "  " << str.substr(start, pos - start) << endl;
        vs->push_back(str.substr(start, pos - start));

        //(*vs)[i++] = string(str, start, pos);
        start = pos + SEP_LEN;
    }
    if (start < str.size())
    {
        //cout << "测试12：" << string(str, start) << "" << endl;
        vs->push_back(string(str, start));
    }
    return true;
}
